/**
 * 
 */
package com.td.framework.webmanager.ymgn.action;

import java.util.List;

import com.td.framework.common.AbstractAction;
import com.td.framework.webmanager.domain.AppsysQxygns;
import com.td.framework.webmanager.domain.AppsysYmgnan;
import com.td.framework.webmanager.qxygns.service.QxygnsService;
import com.td.framework.webmanager.ymgn.service.YmgnService;
import com.opensymphony.xwork2.Action;

/**
 * 
 * Title:处理页面功能信息Action Description: 处理页面功能信息 Copyright: Copyright (c) 2008
 * Company 北京xx能源软件有限公司
 * 
 * @author FLT006
 * @version 1.0
 */
public class YmgnAction extends AbstractAction implements Action {

	private static final long serialVersionUID = 1L;
	private YmgnService ymgnService = null;// 页面功能业务层接口
	private QxygnsService qxygnsService = null;// 权限与功能树业务接口;
	private AppsysYmgnan ymgnan = null;// 页面功能
	private List<AppsysYmgnan> ymgnanList = null;// 页面功能list
	private List<AppsysQxygns> treeList = null;// 生成功能树List;
	private String anbh = "";// 功能编号;
	private String ymbh = "";//页面编号;
	private String anbhs = "";// 功能编号组;
	private Long sjbh = new Long(0);//上级编号;
	private String target = "";// 目标参数;

	/**
	 * @toDo:通过页面名称查询页面功能列表;
	 * @return target;
	 */
	public String listYmgn() {
		int rows = ymgnService.getRows(ymgnan,ymbh);
		page = pageService.getPage(rows, currentPage, pageSize, pageMethod);
		this.setCurrentPage(page.getCurentPage());
		//this.setTotalRows(String.valueOf(rows));
		this.setPageSize(page.getPageSize());
		ymgnanList = ymgnService.findByAnmc(page.getPageSize(), page
				.getStartRow());
		target = "list";
		return target;
	}
	/**
	 * @toDo:生成功能树;
	 * @return target;
	 */
	@SuppressWarnings("unchecked")
	public String listQxygnsTree() {
		treeList = qxygnsService.getTreeList();
		target = "qxygnsTree";
		return target;
	}
	/**
	 * @toDo:查询全部页面功能列表;
	 * @return target;
	 */
	public String listYmgnAll() {
		//ymgnList = ymgnService.findAll();
		target = "allList";
		return target;
	}

	/**
	 * @toDo:查询页面功能对象;
	 * @return target;
	 */
	public String infoYmgn() {
		ymgnan = ymgnService.getAppsysYmgnan(Long.parseLong(anbh));
		target = "info";
		return target;
	}

	/**
	 * @toDo:生成页面功能添加表单;
	 * @return target;
	 */
	public String createYmgnForm() {
		target = "createForm";
		ymgnan = new AppsysYmgnan();
		ymgnan.setYmbh(ymbh);
		ymgnan.setSjbh(sjbh);
		return target;
	}

	/**
	 * @toDo:保存页面功能;
	 * @return target;
	 */
	public String createYmgn() {
		if (ymgnService.addAppsysYmgnan(ymgnan)) {
			this.handleMessage("info", "添加成功,请继续操作!");
			ymbh = ymgnan.getYmbh();
			sjbh = ymgnan.getSjbh();
			ymgnan = new AppsysYmgnan();
			ymgnan.setYmbh(ymbh);
			ymgnan.setSjbh(sjbh);
			target = "addSuccess";
		} else {
			this.handleMessage("info", "添加失败,您添加的信息不符合要求,请重新添加!");
			target = "addFailure";
		}
		return target;
	}

	/**
	 * @toDo:生成页面功能编辑表单;
	 * @return target;
	 */
	public String reworkYmgnForm() {
		ymgnan = ymgnService.getAppsysYmgnan(Long.parseLong(anbhs.split(",")[0]));
		target = "reworkForm";
		return target;
	}

	/**
	 * @toDo: 更新页面功能;
	 * @return target;
	 */
	public String reworkYmgn() {
		String result="";
		if (ymgnService.updateAppsysYmgnan(ymgnan)) {
			target = "updateSuccess";
			result = "OK";
			ymgnan = null;
		} else {
			this.handleMessage("info", "修改失败,请重新修改!");
			target = "updateFailure";
			result = "failure";
		}
		return target;
	}

	/**
	 * @toDo:删除页面功能;
	 * @return target;
	 */
	public String removeYmgn() {
		ymgnService.deleteAppsysYmgnan(anbhs.split(","));
		target = "deleteSuccess";
		return target;
	}

	/**
	 * @toDo:get页面功能业务层接口 ;
	 * @return the ymgnService ;
	 */
	public YmgnService getYmgnService() {
		return ymgnService;
	}

	/**
	 * @toDo:se页面功能业务层接口t ;
	 * @param ymgnService
	 *            the ymgnService to set
	 */
	public void setYmgnService(YmgnService ymgnService) {
		this.ymgnService = ymgnService;
	}

	/**
	 * @toDo:get页面功能;
	 * @return the ymgn;
	 */
	public AppsysYmgnan getYmgnan() {
		return ymgnan;
	}

	/**
	 * @toDo:set页面功能;
	 * @param ymgn
	 *            the ymgn to set
	 */
	public void setYmgnan(AppsysYmgnan ymgnan) {
		this.ymgnan = ymgnan;
	}

	/**
	 * @toDo:get页面功能list ;
	 * @return the ymgnList;
	 */
	public List<AppsysYmgnan> getYmgnanList() {
		return ymgnanList;
	}

	/**
	 * @toDo:set页面功能list ;
	 * @param ymgnList
	 *            the ymgnList to set
	 */
	public void setYmgnanList(List<AppsysYmgnan> ymgnanList) {
		this.ymgnanList = ymgnanList;
	}


	/**
	 * @toDo:get目标参数 ;
	 * @return the target;
	 */
	public String getTarget() {
		return target;
	}

	/**
	 * @toDo:set目标参数 ;
	 * @param target
	 *            the target to set
	 */
	public void setTarget(String target) {
		this.target = target;
	}
	/**
	 * toDo:get
	 * @return treeList
	 */
	public List<AppsysQxygns> getTreeList() {
		return treeList;
	}
	/**
	 * toDo:set
	 * @param treeList 
	 */
	public void setTreeList(List<AppsysQxygns> treeList) {
		this.treeList = treeList;
	}
	/**
	 * toDo:get
	 * @return qxygnsService
	 */
	public QxygnsService getQxygnsService() {
		return qxygnsService;
	}
	/**
	 * toDo:set
	 * @param qxygnsService 
	 */
	public void setQxygnsService(QxygnsService qxygnsService) {
		this.qxygnsService = qxygnsService;
	}
	/**
	 * toDo:get
	 * @return ymbh
	 */
	public String getYmbh() {
		return ymbh;
	}
	/**
	 * toDo:set
	 * @param ymbh 
	 */
	public void setYmbh(String ymbh) {
		this.ymbh = ymbh;
	}
	/**
	 * toDo:get
	 * @return anbh
	 */
	public String getAnbh() {
		return anbh;
	}
	/**
	 * toDo:set
	 * @param anbh 
	 */
	public void setAnbh(String anbh) {
		this.anbh = anbh;
	}
	/**
	 * toDo:get
	 * @return anbhs
	 */
	public String getAnbhs() {
		return anbhs;
	}
	/**
	 * toDo:set
	 * @param anbhs 
	 */
	public void setAnbhs(String anbhs) {
		this.anbhs = anbhs;
	}
	/**
	 * toDo:get
	 * @return sjbh
	 */
	public Long getSjbh() {
		return sjbh;
	}
	/**
	 * toDo:set
	 * @param sjbh 
	 */
	public void setSjbh(Long sjbh) {
		this.sjbh = sjbh;
	}
}
